package com.wswy.wyjk.ui.common

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.wswy.wyjk.model.PracticeType
import com.wswy.wyjk.ui.EXTRA_DATA
import com.wswy.wyjk.ui.REQUEST_CODE_CHOOSE_CITY
import com.wswy.wyjk.ui.main.MainActivity
import com.wswy.wyjk.ui.main.choose.PracticeTypeActivity
import com.wswy.wyjk.ui.practice.PracticeActivity

object Router {

    const val MAIN = "main"

    /**
     * 选择练习类型
     */
    const val CHOOSE_TYPE = "choose_type"

    /**
     * 练习模式
     */
    const val PRACTICE = "practice"

    /**
     * 章节列表
     */
    const val CHAPTER_LIST = "chapter_list"

    /**
     * 选择城市
     */
    const val CHOOSE_CITY = "choose_city"

    /**
     * 考试结果
     */
    const val EXAM_RESULT = "exam_result"

    /**
     * 考试记录
     */
    const val EXAM_RECORD = "exam_record"


    @JvmStatic
    fun start(context:Context, path:String,bundle: Bundle?=null,practiceType: PracticeType?=null){
        when(path){

            MAIN -> {
                context.startActivity(Intent(context, MainActivity::class.java))
            }

            CHOOSE_TYPE -> {
                context.startActivity(Intent(context, PracticeTypeActivity::class.java))
            }
            PRACTICE -> {
                context.startActivity(Intent(context, PracticeActivity::class.java).apply {

                    putExtra(EXTRA_DATA,practiceType)

                })
            }


            CHOOSE_CITY -> {

                (context as? Activity)?.startActivityForResult(Intent(context,CommonActivity::class.java).apply {
                    putExtra("path",path)
                    putExtra(EXTRA_DATA,bundle)
                },
                    REQUEST_CODE_CHOOSE_CITY)
            }

            else -> {
                context.startActivity(Intent(context,CommonActivity::class.java).apply {
                    putExtra("path",path)
                    putExtra(EXTRA_DATA,bundle)
                })
            }

        }



    }

}